<?php
class Visitor_model extends DNN_model
{
	protected  $_table = 'site_visitors';
	
	function __construct() {
		parent::__construct();
	}
	
	function today() {
		$this->db->select('count(id) as count_value');
		$this->db->from($this->_table);
		$this->db->where('DAY(created_date)', date('d'));
		$row = $this->db->get()->row();
		if ($row !== null) {
			return $row->count_value;
		} else {
			return 0;
		}
	}
	function last_week() {
		$this->db->select('count(id) as count_value');
		$this->db->from($this->_table);
		$this->db->where('WEEK(created_date)', date('W')-1);
		$row = $this->db->get()->row();
		if ($row !== null) {
			return $row->count_value;
		} else {
			return 0;
		}
	}
	function last_month() {
		$this->db->select('count(id) as count_value');
		$this->db->from($this->_table);
		$this->db->where('MONTH(created_date)', date('m')-1);
		$row = $this->db->get()->row();
		if ($row !== null) {
			return $row->count_value;
		} else {
			return 0;
		}
	}
}
?>